package com.richard.demo.service;

import com.richard.demo.dao.UserLoginDao;
import com.richard.demo.entity.UserLoginEntity;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserLoginService {
    @Autowired //自动装配，自动给他创建一个对象并实例化
    UserLoginDao userLoginDao;

    public static UserLoginService userLoginService;//单例模式(内存中只保留一份对象)

    @PostConstruct
    public void init() {
        userLoginService = this;
        userLoginService.userLoginDao = this.userLoginDao;
    }

    public List<UserLoginEntity> login(String user, String password) {
        return userLoginDao.login(user, password);
    }
}
